#include "registroMatrizInicial.h"

registroMatrizInicial::registroMatrizInicial(unsigned int nro_doc,unsigned int rep, std::string term) {
    this->nro_documento = nro_doc;
    this->repeticiones = rep;
    this->termino = term;
}
/* ***NUEVO*** */
registroMatrizInicial::registroMatrizInicial(unsigned int nro_doc,unsigned int rep, std::string term,unsigned int* vecPosTerm) {
    this->nro_documento = nro_doc;
    this->repeticiones = rep;
    this->termino = term;
    this->vecPosTerm = new unsigned int[rep];
    memcpy(this->vecPosTerm,vecPosTerm,rep*sizeof(int));
}

registroMatrizInicial::registroMatrizInicial(const registroMatrizInicial& orig) {
	this->nro_documento = orig.nro_documento;
	this->repeticiones = orig.repeticiones;
	this->termino = orig.termino;
	this->vecPosTerm = new unsigned int[orig.repeticiones];
	memcpy(this->vecPosTerm,orig.vecPosTerm,(orig.repeticiones)*sizeof(int));
}

registroMatrizInicial::~registroMatrizInicial() {
	delete [] this->vecPosTerm;
}

bool operator<(registroMatrizInicial& reg1,registroMatrizInicial& reg2){
    if(reg1.termino < reg2.termino )
        return true;
    else if (reg1.termino == reg2.termino and reg1.nro_documento < reg2.nro_documento)
        return true;
    
    return false;
}

bool registroMatrizInicial::operator<(registroMatrizInicial& reg1){
    if(this->termino < reg1.termino)
        return true;
    else if (this->termino == reg1.termino && this->nro_documento < reg1.nro_documento)
        return true;
    
    return false;
}

bool operator==(registroMatrizInicial& reg1,registroMatrizInicial& reg2){
    if(reg1.termino == reg2.termino and reg1.nro_documento == reg2.nro_documento)
        return true;
    return false;
}


void registroMatrizInicial::aumentarFrecuencia(){
    this->repeticiones++;
}
